import 'package:json_annotation/json_annotation.dart';

part 'word.g.dart';

@JsonSerializable()
class Word {
  final String id;
  final String esperanto;
  final String english;
  final String pronunciation;
  final String definition;
  final List<String> examples;
  final String category;
  final String audioUrl;
  final bool isFavorite;
  final int difficulty;

  const Word({
    required this.id,
    required this.esperanto,
    required this.english,
    required this.pronunciation,
    required this.definition,
    required this.examples,
    required this.category,
    required this.audioUrl,
    this.isFavorite = false,
    this.difficulty = 1,
  });

  factory Word.fromJson(Map<String, dynamic> json) => _$WordFromJson(json);

  Map<String, dynamic> toJson() => _$WordToJson(this);

  Word copyWith({
    String? id,
    String? esperanto,
    String? english,
    String? pronunciation,
    String? definition,
    List<String>? examples,
    String? category,
    String? audioUrl,
    bool? isFavorite,
    int? difficulty,
  }) {
    return Word(
      id: id ?? this.id,
      esperanto: esperanto ?? this.esperanto,
      english: english ?? this.english,
      pronunciation: pronunciation ?? this.pronunciation,
      definition: definition ?? this.definition,
      examples: examples ?? this.examples,
      category: category ?? this.category,
      audioUrl: audioUrl ?? this.audioUrl,
      isFavorite: isFavorite ?? this.isFavorite,
      difficulty: difficulty ?? this.difficulty,
    );
  }
} 